

#include <graphics.h>
#include <stdio.h>
#include <math.h>

      
   int N=18,M,m,k,ch,i,j;
   double A[20][20],B[20],X[20],X1[20],e,norm,cash,S;

main()
{ 
    
    initwindow(400, 300, "norm(N)");
    setcolor(BLACK); 
    setbkcolor(WHITE);

    cleardevice();
    
    int x0=100, y0=200;   
    int x1=300, y1=100;   

    moveto(x0,y0);
    lineto(x0,y1);
    moveto(x0,y0);
    lineto(x1,y0);
    moveto(x0-3,y1+5);
    lineto(x0,y1);
    moveto(x0+3,y1+5);
    lineto(x0,y1);   
    moveto(x1,y0);
    lineto(x1-5,y0-3);
    moveto(x1-5,y0+3);
    lineto(x1,y0);      
    printf( "e              norm\n");            

   printf( "\n"); 


    
    e=0.001;
    for(ch=1;ch<=19;ch++)
    {
    M=N;
    e=e/1.65;
    
    

     

    for(m=1;m<=N;m++)
    {
       for(k=1;k<=M;k++)
       {
          if (m=k) A[k][m]=1+e;
       } 
    }  
    for(m=1;m<=N;m++)
    {
       for(k=1;k<=M;k++)
       {
          if (m<k) A[k][m]=e;
       } 
    }  
    for(m=1;m<=N;m++)
    {
       for(k=1;k<=M;k++)
       {
          if (m>k) A[k][m]=-1-e;
       } 
    } 
    for(k=1;k<=M-1;k++)
    {
       B[k]=-1;
    } 
    B[M]=1+e ;
    

    for (j=1;j<N;j++) 
    {
      cash=A[j][j];  
      for (k=1;k<=N;k++)     
      {
          A[j][k]=A[j][k]/cash;
      }
      B[j]=B[j]/cash;
      for (i=j+1;i<=N;i++)
      {
          cash=A[i][j];
          for(k=1;k<=N;k++)
          {
            A[i][k]=A[i][k]-cash*A[j][k];              
          }
          B[i]=B[i]-cash*B[j];
      }  

      
    }



    for (i=N; i>0; i--) 
    {
       S=B[i];
       for(j=N;j>i;j--)
       {
         S=S-X[j]*A[i][j];                
       }
       X[i]=S/A[i][i];
    }
    norm=0;
    for (i=1;i<=N;i++)
      {
        norm+=X[i]*X[i];
      }
    norm=sqrt(norm); 

    printf( "%2.9f   %2.9f\n",e,norm);
    fillellipse(101+ch*10,200-(int)((norm-1)*2000),1,1);

  }
          
              
  
 

    getchar();
    closegraph();
  return 0;
}      
  
  
  
  
  
